package com.app.backend.base.controller;

import com.app.backend.common.annotation.InvokeLog;
import com.app.backend.common.service.LogService;
import com.app.backend.common.base.BaseController;
import com.app.backend.common.base.BaseService;
import com.app.backend.common.base.PageEntity;
import com.app.backend.common.entity.Log;
import com.app.backend.common.response.BaseResponse;
import com.app.backend.common.utils.PageUtil;
import com.app.backend.common.vo.LogVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

/**
 * @program: LogController
 * @description:
 * @author: Zhun.Xiao
 * @create: 2020-02-10 12:31
 **/


@Slf4j
@RestController
@Api(value = "日志接口")
@RequestMapping(value = "/api/v1/log")
public class LogController extends BaseController<Log, String> {


    @Autowired
    private LogService logService;

    @Override
    protected BaseService<Log, String> getService() {
        return logService;
    }


    @PostMapping(value = "/find")
    @ResponseBody
    @ApiOperation(value = "获取全部数据")
    @InvokeLog(description = "根据username查找user")
    public BaseResponse findByConditionPage(@RequestBody LogVo logVo) {
        PageEntity pageEntity = PageEntity.valueOf(logVo);
        Pageable pageable = PageUtil.initPage(pageEntity);
        return new BaseResponse(logService.findByConditionPage(logVo, pageable));
    }

}